package com.wn.listener;

import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

/**
 * @author yellow Docter
 * @date 2022 -07-05
 * @desc
 *   监听session的创建和销毁
 *
 *   HttpSessionAttributeListener 监听session的属性的变化
 *
 *    attributeAdded    属性的添加
 *
 *    attributeRemoved  属性的移除
 *
 *    attributeReplaced  属性的替换
 *
 */
@WebListener
public class MySessionAttrListener implements HttpSessionAttributeListener {

    @Override
    public void attributeAdded(HttpSessionBindingEvent se) {

        System.out.println("attributeAdded    属性的添加");
    }

    @Override
    public void attributeRemoved(HttpSessionBindingEvent se) {
        System.out.println("attributeRemoved  属性的移除");
    }

    @Override
    public void attributeReplaced(HttpSessionBindingEvent se) {
        System.out.println("attributeReplaced  属性的替换");
    }
}
